var fs = require("fs");

var ids = [];
var blocks = [];

var BLOCK_TO_ID = false; // false - ID to Block

blocks.push("stone") 
blocks.push("granite") 
blocks.push("polished_granite") 
blocks.push("diorite") 
blocks.push("polished_diorite") 
blocks.push("andesite") 
blocks.push("polished_andesite") 
blocks.push("deepslate") 
blocks.push("cobbled_deepslate") 
blocks.push("polished_deepslate") 
blocks.push("calcite") 
blocks.push("tuff") 
blocks.push("dripstone_block") 
blocks.push("dirt") 
blocks.push("coarse_dirt") 
blocks.push("podzol") 
blocks.push("rooted_dirt") 
blocks.push("mud") 
blocks.push("cobblestone") 
blocks.push("oak_planks") 
blocks.push("spruce_planks") 
blocks.push("birch_planks") 
blocks.push("jungle_planks") 
blocks.push("acacia_planks") 
blocks.push("dark_oak_planks") 
blocks.push("mangrove_planks") 
blocks.push("crimson_planks") 
blocks.push("warped_planks") 
blocks.push("bedrock") 
blocks.push("sand") 
blocks.push("red_sand") 
blocks.push("gravel") 
blocks.push("coal_ore") 
blocks.push("deepslate_coal_ore") 
blocks.push("iron_ore") 
blocks.push("deepslate_iron_ore") 
blocks.push("copper_ore") 
blocks.push("deepslate_copper_ore") 
blocks.push("gold_ore") 
blocks.push("deepslate_gold_ore") 
blocks.push("redstone_ore") 
blocks.push("deepslate_redstone_ore") 
blocks.push("emerald_ore") 
blocks.push("deepslate_emerald_ore") 
blocks.push("lapis_ore") 
blocks.push("deepslate_lapis_ore") 
blocks.push("diamond_ore") 
blocks.push("deepslate_diamond_ore") 
blocks.push("nether_gold_ore") 
blocks.push("nether_quartz_ore") 
blocks.push("ancient_debris") 
blocks.push("coal_block") 
blocks.push("raw_iron_block") 
blocks.push("raw_copper_block") 
blocks.push("raw_gold_block") 
blocks.push("amethyst_block") 
blocks.push("budding_amethyst") 
blocks.push("iron_block") 
blocks.push("copper_block") 
blocks.push("gold_block") 
blocks.push("diamond_block") 
blocks.push("netherite_block") 
blocks.push("waxed_copper_block") 
blocks.push("waxed_exposed_copper") 
blocks.push("waxed_weathered_copper") 
blocks.push("waxed_oxidized_copper") 
blocks.push("waxed_cut_copper") 
blocks.push("waxed_exposed_cut_copper") 
blocks.push("waxed_weathered_cut_copper") 
blocks.push("waxed_oxidized_cut_copper") 
blocks.push("waxed_cut_copper_stairs") 
blocks.push("waxed_exposed_cut_copper_stairs") 
blocks.push("waxed_weathered_cut_copper_stairs") 
blocks.push("waxed_oxidized_cut_copper_stairs") 
blocks.push("waxed_cut_copper_slab") 
blocks.push("waxed_exposed_cut_copper_slab") 
blocks.push("waxed_weathered_cut_copper_slab") 
blocks.push("waxed_oxidized_cut_copper_slab") 
blocks.push("oak_log") 
blocks.push("spruce_log") 
blocks.push("birch_log") 
blocks.push("jungle_log") 
blocks.push("dark_oak_log") 
blocks.push("mangrove_log") 
blocks.push("muddy_mangrove_roots") 
blocks.push("crimson_stem") 
blocks.push("warped_stem") 
blocks.push("stripped_oak_log") 
blocks.push("stripped_spruce_log") 
blocks.push("stripped_birch_log") 
blocks.push("stripped_jungle_log") 
blocks.push("stripped_dark_oak_log") 
blocks.push("stripped_mangrove_log") 
blocks.push("stripped_crimson_stem") 
blocks.push("stripped_warped_stem") 
blocks.push("stripped_oak_wood") 
blocks.push("stripped_spruce_wood") 
blocks.push("stripped_birch_wood") 
blocks.push("stripped_jungle_wood") 
blocks.push("stripped_dark_oak_wood") 
blocks.push("stripped_mangrove_wood") 
blocks.push("stripped_crimson_hyphae") 
blocks.push("stripped_warped_hyphae") 
blocks.push("oak_wood") 
blocks.push("spruce_wood") 
blocks.push("birch_wood") 
blocks.push("jungle_wood") 
blocks.push("dark_oak_wood") 
blocks.push("mangrove_wood") 
blocks.push("crimson_hyphae") 
blocks.push("warped_hyphae") 
blocks.push("sponge") 
blocks.push("glass") 
blocks.push("tinted_glass") 
blocks.push("lapis_block") 
blocks.push("sandstone") 
blocks.push("chiseled_sandstone") 
blocks.push("cut_sandstone") 
blocks.push("cobweb") 
blocks.push("white_wool") 
blocks.push("orange_wool") 
blocks.push("magenta_wool") 
blocks.push("light_blue_wool") 
blocks.push("yellow_wool") 
blocks.push("lime_wool") 
blocks.push("pink_wool") 
blocks.push("gray_wool") 
blocks.push("light_gray_wool") 
blocks.push("cyan_wool") 
blocks.push("purple_wool") 
blocks.push("blue_wool") 
blocks.push("brown_wool") 
blocks.push("green_wool") 
blocks.push("red_wool") 
blocks.push("black_wool") 
blocks.push("white_terracotta") 
blocks.push("orange_terracotta") 
blocks.push("magenta_terracotta") 
blocks.push("light_blue_terracotta") 
blocks.push("yellow_terracotta") 
blocks.push("lime_terracotta") 
blocks.push("pink_terracotta") 
blocks.push("gray_terracotta") 
blocks.push("light_gray_terracotta") 
blocks.push("cyan_terracotta") 
blocks.push("purple_terracotta") 
blocks.push("blue_terracotta") 
blocks.push("brown_terracotta") 
blocks.push("green_terracotta") 
blocks.push("red_terracotta") 
blocks.push("black_terracotta") 
blocks.push("white_stained_glass") 
blocks.push("orange_stained_glass") 
blocks.push("magenta_stained_glass") 
blocks.push("light_blue_stained_glass") 
blocks.push("yellow_stained_glass") 
blocks.push("lime_stained_glass") 
blocks.push("pink_stained_glass") 
blocks.push("gray_stained_glass") 
blocks.push("light_gray_stained_glass") 
blocks.push("cyan_stained_glass") 
blocks.push("purple_stained_glass") 
blocks.push("blue_stained_glass") 
blocks.push("brown_stained_glass") 
blocks.push("green_stained_glass") 
blocks.push("red_stained_glass") 
blocks.push("black_stained_glass") 
blocks.push("white_concrete") 
blocks.push("orange_concrete") 
blocks.push("magenta_concrete") 
blocks.push("light_blue_concrete") 
blocks.push("yellow_concrete") 
blocks.push("lime_concrete") 
blocks.push("pink_concrete") 
blocks.push("gray_concrete") 
blocks.push("light_gray_concrete") 
blocks.push("cyan_concrete") 
blocks.push("purple_concrete") 
blocks.push("blue_concrete") 
blocks.push("brown_concrete") 
blocks.push("green_concrete") 
blocks.push("red_concrete") 
blocks.push("black_concrete") 
blocks.push("white_concrete_powder") 
blocks.push("orange_concrete_powder") 
blocks.push("magenta_concrete_powder") 
blocks.push("light_blue_concrete_powder") 
blocks.push("yellow_concrete_powder") 
blocks.push("lime_concrete_powder") 
blocks.push("pink_concrete_powder") 
blocks.push("gray_concrete_powder") 
blocks.push("light_gray_concrete_powder") 
blocks.push("cyan_concrete_powder") 
blocks.push("purple_concrete_powder") 
blocks.push("blue_concrete_powder") 
blocks.push("brown_concrete_powder") 
blocks.push("green_concrete_powder") 
blocks.push("red_concrete_powder") 
blocks.push("black_concrete_powder") 
blocks.push("white_shulker_box") 
blocks.push("orange_shulker_box") 
blocks.push("magenta_shulker_box") 
blocks.push("light_blue_shulker_box") 
blocks.push("yellow_shulker_box") 
blocks.push("lime_shulker_box") 
blocks.push("pink_shulker_box") 
blocks.push("gray_shulker_box") 
blocks.push("light_gray_shulker_box") 
blocks.push("cyan_shulker_box") 
blocks.push("purple_shulker_box") 
blocks.push("blue_shulker_box") 
blocks.push("brown_shulker_box") 
blocks.push("green_shulker_box") 
blocks.push("red_shulker_box") 
blocks.push("black_shulker_box") 
blocks.push("white_glazed_terracotta") 
blocks.push("orange_glazed_terracotta") 
blocks.push("magenta_glazed_terracotta") 
blocks.push("light_blue_glazed_terracotta") 
blocks.push("yellow_glazed_terracotta") 
blocks.push("lime_glazed_terracotta") 
blocks.push("pink_glazed_terracotta") 
blocks.push("gray_glazed_terracotta") 
blocks.push("light_gray_glazed_terracotta") 
blocks.push("cyan_glazed_terracotta") 
blocks.push("purple_glazed_terracotta") 
blocks.push("blue_glazed_terracotta") 
blocks.push("brown_glazed_terracotta") 
blocks.push("green_glazed_terracotta") 
blocks.push("red_glazed_terracotta") 
blocks.push("black_glazed_terracotta") 
blocks.push("white_stained_glass_pane") 
blocks.push("orange_stained_glass_pane") 
blocks.push("magenta_stained_glass_pane") 
blocks.push("light_blue_stained_glass_pane") 
blocks.push("yellow_stained_glass_pane") 
blocks.push("lime_stained_glass_pane") 
blocks.push("pink_stained_glass_pane") 
blocks.push("gray_stained_glass_pane") 
blocks.push("light_gray_stained_glass_pane") 
blocks.push("cyan_stained_glass_pane") 
blocks.push("purple_stained_glass_pane") 
blocks.push("blue_stained_glass_pane") 
blocks.push("brown_stained_glass_pane") 
blocks.push("green_stained_glass_pane") 
blocks.push("red_stained_glass_pane") 
blocks.push("black_stained_glass_pane") 
blocks.push("dried_kelp_block") 
blocks.push("crying_obsidian") 
blocks.push("obsidian") 
blocks.push("blackstone") 
blocks.push("gilded_blackstone") 
blocks.push("polished_blackstone") 
blocks.push("chiseled_polished_blackstone") 
blocks.push("polished_blackstone_bricks") 
blocks.push("cracked_polished_blackstone_bricks")

var i = 0;
while(i < 135) {
    ids.push(i);
    i++;
}
ids.push(255);
i = 135;
while(i < 256) {
    ids.push(i);
    i++;
}

var string = "";

if(BLOCK_TO_ID) {
    // execute as @e[tag=pointer] if block ~ ~-1 ~ stone run scoreboard players set rax register 0
    i = 0;
    while(i < 256) {
        string += `execute as @e[tag=pointer] if block ~ ~-1 ~ ${blocks[i]} run scoreboard players set rax register ${ids[i]}\n`;
        i++;
    }
} else {
    i = 0;
    while(i < 256) {
        // execute as @e[tag=pointer] if score rax register matches 1 run setblock ~ ~-1 ~ stone
        string += `execute as @e[tag=pointer] if score rax registers matches ${ids[i]} run setblock ~ ~-1 ~ ${blocks[i]}\n`;
        i++;
    }
}

fs.writeFileSync((BLOCK_TO_ID) ? "getbyte.mcfunction" : "setbyte.mcfunction", string);